package com.jeecg.school.dao.impl;


import java.io.IOException;
import java.io.InputStream;
 
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
	
public class DBAccess {
	public static SqlSession getSqlSession() throws IOException{
	   //配置文件的路径
		String resource = "mybatis.cfg.xml";
		//通过配置文件获取数据库连接信息
		InputStream inputStream = Resources.getResourceAsStream(resource);
		SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
		SqlSessionFactory sqlSessionFactory = builder.build(inputStream);
		SqlSession session = sqlSessionFactory.openSession();
		return session;
	}

}
